# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=field3d

pkgname="${MINGW_PACKAGE_PREFIX}-${_realname}"
pkgver=1.4.3
pkgrel=1
pkgdesc="Open source library for storing voxel data (mingw-w64)"
arch=('any')
url="https://sites.google.com/site/field3d/"
license=("custom")
depends=("${MINGW_PACKAGE_PREFIX}-boost"
        "${MINGW_PACKAGE_PREFIX}-hdf5"
        "${MINGW_PACKAGE_PREFIX}-openexr")
makedepends=("${MINGW_PACKAGE_PREFIX}-cmake" "${MINGW_PACKAGE_PREFIX}-gcc")
options=('strip' 'buildflags')
source=(https://github.com/imageworks/Field3D/archive/v${pkgver}.tar.gz
        cmake-mingw.patch)
md5sums=('f76d8537f1d058ede0bcb14fbc09e28c'
         'ceaf0f2e8b9afb0b3a3ae117ff2553e4')

prepare() {
  cd ${srcdir}/Field3D-${pkgver}
  patch -p1 -i ${srcdir}/cmake-mingw.patch
  #patch -p1 -i ${srcdir}/workaround-ansidecl-h-PTR-define-conflict.patch
}

build() {
  [[ -d build-${MINGW_CHOST} ]] && rm -r build-${MINGW_CHOST}
  mkdir build-${MINGW_CHOST} && cd build-${MINGW_CHOST}
  
  ${MINGW_PREFIX}/bin/cmake.exe \
    -G"MSYS Makefiles" \
    -DCMAKE_INSTALL_PREFIX=${pkgdir}${MINGW_PREFIX} \
    ../Field3D-${pkgver}
  make
}

package() {
  cd "$srcdir"/build-${MINGW_CHOST}

  make install
}
